package com.symaster.backups;

import com.symaster.backups.frame.MainFrame;
import com.symaster.backups.frame.trayicon.ApplicationTrayIcon;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.awt.*;

/**
 * @author yinmiao
 * @version 2024/2/5
 */
@Component
public class ApplicationRunnerImpl implements ApplicationRunner {
    private final MainFrame mainFrame;
    private final ApplicationTrayIcon applicationTrayIcon;

    @Autowired
    public ApplicationRunnerImpl(MainFrame mainFrame, ApplicationTrayIcon applicationTrayIcon) {
        this.mainFrame = mainFrame;
        this.applicationTrayIcon = applicationTrayIcon;
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        SystemTray.getSystemTray().add(applicationTrayIcon);
        mainFrame.open();
    }
}
